import { makeAutoObservable, runInAction } from 'mobx'

const user = makeAutoObservable({
  info: { id: '', username: '', nickname: '' },
  get isLogin() {
    return Boolean(this.info.id)
  },

  async login() {
    try {
      runInAction(() => {
        user.info = { id: '123', username: 'kkk', nickname: 'fffff' }
      })
    } catch (err) {
      console.error(err)
    }
  },
  logout() {},
})

export default user
